# _*_ coding: UTF-8 _*_
# @Time     : 2020/10/15 上午 10:57
# @Author   : Li Jie
# @Site     : http://www.cdtest.cn/
# @File     : sequence_test.py
# @Software : PyCharm

# 序列sequence
# 有序的队列
# 列表、元祖、字符串都是序列
# 字典不是序列


print('------------------------------')
# 索引的操作
# 索引/下标一般是整数，或者算术表达式，整数变量
# 索引可以是正数也可以是负数,代表倒数第几个元素
list1 = [1, 2, 3]
tuple1 = (1, 2, 3)
print(list1[-1])
print(tuple1[-1])

print('--------------------------------')
# 序列中包含序列
list1 = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
]
print(list1[0][0])
print(list1[1][1])
print(list1[2][2])

# 遍历
for i in list1:
    for j in i:
        print(j, end=',')
    print()

print('--------------------------------')
# 序列的切片：sequence[start:end:step]
# 切片操作包左不包右
list1 = [1, 2, 3, 4, 5, 6]
tuple1 = (1, 2, 3, 4, 5, 6)
print(list1[1:2])
print(tuple1[:2])
print(list1[1:])
print(tuple1[::2])



print('--------------------------------')
#序列相加
list1 = [1,2,3]
list2 = [4,5,6]
tuple1 = (4,5,6)
list3 = list1+list2
print(list3)
# print(list1+tuple1)






